#include <iostream>
typedef char Elemtype;
using namespace std;


// #define Elemtype char
//带头结点单链表
typedef struct LinkNode
{
    Elemtype data;
    LinkNode *next;
}Node,*LinkStack;

//构造空链表
void InitStack(LinkStack &S){
    S=new Node;
    S->next=NULL;
}

void push(LinkStack &S,Elemtype e){
    Node *p=new Node;
    p->data=e;

    p->next=S->next;
    S->next=p;
}
//判断空
bool isEmpty(LinkStack &S){
    return S->next==NULL;
}

//取栈顶元素
bool getTop(LinkStack &S,Elemtype &e){
    if(isEmpty(S)){
        return false;
    }
    e=S->next->data;
    return true;
}
//放栈顶元素
bool pop(LinkStack &S,Elemtype &e){
    if(isEmpty(S)){
        return false;
    }
    Node *p;
    e=S->next->data;
    p=S->next;
    S->next=p->next;
    delete p;
    return true;
}
//求链栈长度
int length(LinkStack &S)
{
int i=0;
Node *p=S;
while(p->next!=NULL){
        p=p->next;
        i++;
    }
return i;
}
//输出栈顶到栈底元素
void Element(LinkStack &S){
    Node *p=S;
    while(p->next!=NULL){
    p=p->next;
    cout<<p->data<<" ";
    }
}
int main()
{
    //（1）初始化链栈S;
	LinkStack S;
    InitStack(S);
    //（2）判断链栈S是否为空；
    if(isEmpty(S)) cout<<"yes\n";
    else cout<<"no\n";
    //(3)依次进栈元素a，b，c，d，e;
    int num;
    cin>>num;
    for(int i=0;i<num;i++){
        char a;
        cin>>a;
        push(S,a);
    }
    //（4）判断链栈S是否为空；
    if(isEmpty(S)) cout<<"yes\n";
    else cout<<"no\n";
    //（5）输出链栈长度；
    cout<<length(S)<<endl;
    //（6）输出从栈顶到栈底的元素；
    Element(S);
    cout<<endl;
    //（7）输出出栈序列;

    char x;
    while(!isEmpty(S)){
        pop(S,x);
        cout<<x<<" ";
    }
    cout<<endl;
    //（8）判断链栈S是否为空；
    if(isEmpty(S)) cout<<"yes\n";
    else cout<<"no\n";
}